package com.webex.ta.hydra.gui.action;

import com.webex.ta.hydra.gui.GuiPackage;
import com.webex.ta.hydra.gui.table.HydraTable;

import java.awt.event.ActionEvent;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Cisco WebEx.
 * User: vegaz
 * Date: 2010-10-26
 * Time: 16:29:00
 */
public class ToggleExpandAction implements ActionHandler {
    private static Set<String> commands = new HashSet<String>();
	static {
		commands.add(ActionNames.COLLAPSE);
        commands.add(ActionNames.EXPAND);
	}

    public Set<String> getActionNames() {
        return commands;
    }

    public void doAction(ActionEvent e) {
        GuiPackage gp = GuiPackage.getInstance();
        HydraTable table = gp.getHydraTable();
        if (table.getSelectedRow() >= 0) {
            if (ActionNames.COLLAPSE.equals(e.getActionCommand()))
                table.collapse(table.getSelectedRow());
            else if (ActionNames.EXPAND.equals(e.getActionCommand()))
                table.expand(table.getSelectedRow());
        }
    }


}
